<?php
class filter_categoryModel extends baseModel{
    protected $table = 'filter_category';

    //多维分类列表
    public function filter_category_list() {
        return $this->select('','','cid asc');
    }

    //多维分类信息
    public function info($cid) {
        return $this->find('cid='.$cid);
    }

    //添加多维分类
    public function add($data)
    {

        return $this->insert($data);
    }
    //编辑多维分类
    public function edit($data)
    {
        $condition['cid']=intval($data['cid']);
        return $this->update($condition,$data); 
    }
    //删除多维分类
    public function del($cid)
    {
        $list=model('filter_list')->filter_list($cid);
        if(!empty($list)){
            foreach ($list as $value) {
                model('filter_list')->del($value['fid']);
            }
        }
        return $this->delete('cid='.intval($cid)); 
    }

    //APIHTML
    public function filter_list_html($info=array())
    {
        $filter_category_list=$this->filter_category_list();
        $html='
                <div class="formitm">
                    <label class="lab" >多维分类：</label>
                    <div class="ipt">
                        <div class="txt">
                            <select name="filter" id="filter">
                                <option value="0">无</option>';
        if(!empty($filter_category_list)){
            foreach ($filter_category_list as $vo) {
                if($vo['cid']==$info['filter']){
                    $html.='<option value="'.$vo['cid'].'" selected="selected">'.$vo['name'].'</option>';
                }else{
                    $html.='<option value="'.$vo['cid'].'" >'.$vo['name'].'</option>';
                }
            }
        }
        $html.='</select>
                        </div>
                        <span class="Validform_checktip">用于栏目下内容的多属性分类</span> </div>
                </div>
        ';
        return $html;
    }
	
}